<?php
	/*
	 * @author		: Pinga 
	 * @data		: 16/12/2009
	 * @version		: 1.0
	 * @description	: 	Classe para auxilio de navega��o
	 */
	 /*
	 * @autor		: Mauricio Amorim
	 * @data		: 07/07/2010
	 * @versao		: 1.1 (ingl�s)
	 * @description	: 	Classe para auxilio de navega��o
	 */
	/*
	 * @author		: Diego Faria Montania
	 * @data		: 8/7/2010
	 * @version		: 1.2
	 * @description	: 	Agora a classe � est�tica
	 * 					Modo de uso:
	 					//de qualquer lugar do c�digo em que a classe j� tenha sido importada:
	 					$variavel = Navigation::get("teste");
	 */

class Navigation{
	static function get($variable){
		//se tiver vazio ou não estivar setado, retorna null
		return (isset($_GET[$variable]) && !empty($_GET[$variable])) ? $_GET[$variable] : NULL;
	}
	static function post($variable){
		return (isset($_POST[$variable]) && !empty($_POST[$variable])) ? $_POST[$variable] : NULL;
	}
	static function session($variable){
		return (isset($_SESSION) && isset($_SESSION[$variable]))?$_SESSION[$variable]:NULL;
	}
	static function sessionStart(){
		//a vantagem de usar esse metodo � que s� inicia se j� n�o tiver iniciado
		if(!isset($_SESSION)){
			session_start();
		}
	}
	static function getVar($variable){
		//verifica primeiro se n�o mandou por post, se n�o tiver mandado, ve por GET
		if(Navigation::post($variable) !== NULL){
			return Navigation::post($variable);
		} else if(Navigation::get($variable) != NULL){
			return Navigation::get($variable);
		} else {
			return NULL;
		}
	}
	
	function debugg(){
		if(isset($_GET['debugg'])){
			return true;
		}
		return false;
	}
	
	static function setHeaderContentType($ext, $charset = "charset=utf-8"){
		// ver: http://webdesign.about.com/od/multimedia/a/mime-types-by-content-type.htm
		switch($ext){
			case "css":
				header("Content-Type: text/css");
				break;
			
			case "txt":
				header("Content-Type: text/plain");
				break;
			
			case "htm":
			case "html":
				header("Content-Type: text/html; $charset");
				break;
			
			case "js":
				header("Content-Type: text/javascript");
				break;
			
			case "mpg":
				header("Content-Type: video/mpeg");
				break;	
			
			case "mp3":
				header("Content-Type: audio/mpeg");
				break;	
			
			case "jpg":
				header("Content-Type: image/jpeg");
				break;
			
			case "gif":
				header("Content-Type: image/gif");
				break;
			
			case "png":
				header("Content-Type: image/png");
				break;
			
			case "ico":
				header("Content-Type: image/x-icon");
				break;
			
			case "pdf":
				header("Content-Type: application/pdf");
				break;	
			
			case "zip":
				header("Content-Type: application/zip");
				break;	
				
			default:
				echo "extensao desconhecida em Navigation.class.php -> setHeaderContentType()";
				exit();
				break;
				
		}
	}
}
?>